package com.lgx.right.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import com.lgx.common.entity.IdGenerator;

/**
 * 权限
 * 
 * @author acer
 *
 */
@Entity
@Table(name = "TS_PERMISSION")
public class Permission implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4531152958600671635L;

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TS_PERMISSION_ID)
	@TableGenerator(
			name = IdGenerator.TS_PERMISSION_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TS_PERMISSION_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	private String name;
	
	private String level;
	
	@ManyToOne
	@JoinColumn(name="parent")
	private Permission parent;
	
	private String layerOrder;
	
	/**
	 * 0菜单权限，1操作权限
	 */
	private String type;
	
	private String isDelete;
	
	private String isLeaf;
	
	@Transient
	private List<Permission> children = new ArrayList<Permission>();

	public List<Permission> getChildren() {
		return children;
	}

	public void setChildren(List<Permission> children) {
		this.children = children;
	}

	public String getIsLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(String isLeaf) {
		this.isLeaf = isLeaf;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public Permission getParent() {
		return parent;
	}

	public void setParent(Permission parent) {
		this.parent = parent;
	}

	public String getLayerOrder() {
		return layerOrder;
	}

	public void setLayerOrder(String layerOrder) {
		this.layerOrder = layerOrder;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(String isDelete) {
		this.isDelete = isDelete;
	}
}
